package com.itheima79.googleplay.holder;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.itheima79.googleplay.R;
import com.itheima79.googleplay.bean.Subject;
import com.itheima79.googleplay.global.GooglePlayApplication;
import com.itheima79.googleplay.global.ImageLoaderOptions;
import com.itheima79.googleplay.http.Api;
import com.nostra13.universalimageloader.core.ImageLoader;

public class SubjectHolder extends BaseHolder<Subject> {
	private ImageView iv_image;
	private TextView tv_des;
	@Override
	public View initHolderView() {
		View view = View.inflate(GooglePlayApplication.context, R.layout.adapter_subject, null);
		iv_image = (ImageView) view.findViewById(R.id.iv_image);
		tv_des = (TextView) view.findViewById(R.id.tv_des);
		return view;
	}

	@Override
	public void bindData(Subject data) {
		tv_des.setText(data.getDes());
		//1.获取屏幕的宽度
		//2.根据图片的宽高比计算对应的高度
		//3.将高度设置给ImageView
		
		ImageLoader.getInstance().displayImage(Api.IMAGE_PREFIX+data.getUrl(),iv_image,ImageLoaderOptions.fadein_options);
	}

}
